package main

import (
	"errors"
	"fmt"
	"github.com/gin-gonic/gin"
	"k8s-go/api"
	"net/http"
	"os"
	"os/signal"
	"syscall"
)

func main() {
	router := gin.Default()
	apiK8s := &api.K8s{}
	router.GET("/k8s", apiK8s.GetK8sNamespace)

	quit := make(chan os.Signal, 1)
	signal.Notify(quit, syscall.SIGINT, syscall.SIGTERM)
	go func() {
		if err := router.Run(":8090"); err != nil && !errors.Is(err, http.ErrServerClosed) {
			fmt.Println("HTTP server ListenAndServe: ", err)
			return
		}
	}()
	<-quit
	fmt.Println("Server exiting")
}
